class Solution(object):
    def isLongPressedName(self, name, typed):
        """
        :type name: str
        :type typed: str
        :rtype: bool
        """

        def search(s):
            left = 0
            right = 0
            n = len(s)
            out = []
            while right < n:
                if s[right] != s[left]:
                    out.append([s[left], right - left])
                    left = right
                right += 1
            out.append([s[left], right - left])
            return out

        name = search(name)
        typed = search(typed)
        if len(name) != len(typed):
            return False
        for i in range(len(name)):
            if name[i][0] != typed[i][0]:
                return False
            if name[i][1] > 1:
                if typed[i][1] == 1:
                    return False
        return True




data = Solution()
name = "alex"
typed = "aaleex"
print(data.isLongPressedName(name, typed))
